<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>三元表达式</title>
</head>
<body>
    
</body>
</html>
<script>
    // let n = false ? 1 : 2;
    // console.log(n);
    // let f = false ? (1 == true ? 'yes' : 'no') : 3;
    // console.log(f)


    //使用三元表达式创建div元素的实例
    function div(options = {}){
        let div = document.createElement("div");
        div.style.width = options.width ? options.width : '100px';
        div.style.height = options.height ? options.height : '100px';
        div.style.backgroundColor = options.bgcolor ? options.bgcolor : 'red';
        document.body.appendChild(div);
    }
    div({
        width:'200px',
        height:'200px',
        bgcolor:'green'
    });
</script>